package cn.auction.biz.impl;

import cn.auction.biz.AuctionUserService;
import cn.auction.dao.AuctionUserDao;
import cn.auction.dao.impl.AuctionUserDaoImpl;
import cn.auction.entity.AuctionUser;
import my.framework.dao.DatabaseUtil;

public class AuctionUserServiceImpl implements AuctionUserService {
    private AuctionUserDao dao = new AuctionUserDaoImpl();

    public AuctionUserServiceImpl() {
    }

    public AuctionUser login(String userName, String userPassword) throws Exception {
        AuctionUser var3;
        try {
            var3 = this.dao.selectUser(userName, userPassword, false);
        } finally {
            DatabaseUtil.closeConnection();
        }

        return var3;
    }

    public AuctionUser adminlogin(String userName, String userPassword) throws Exception {
        AuctionUser var3;
        try {
            var3 = this.dao.selectUser(userName, userPassword, true);
        } finally {
            DatabaseUtil.closeConnection();
        }

        return var3;
    }

    public void register(AuctionUser user) throws Exception {
        try {
            this.dao.insert(user);
            DatabaseUtil.getConnection().commit();
        } catch (Exception var6) {
            var6.printStackTrace();
            DatabaseUtil.getConnection().rollback();
        } finally {
            DatabaseUtil.closeConnection();
        }

    }
}
